Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MNT: Refactor flight prints module #579

Merged
merged 3 commits into from
Mar 24, 2024

Conversation

Gui-FernandesBR
Copy link
Member

Pull request type

  • Code maintenance (refactoring, formatting, tests)

Checklist

  • Tests for the changes have been added (not needed)
  • Docs have been reviewed and added / updated
  • Lint (black rocketpy/ tests/) has passed locally
  • All tests (pytest tests -m slow --runslow) have passed locally
  • CHANGELOG.md has been updated (if relevant)

Current behavior

The code used within the _FlightPrints class is becoming quite outdated.
It is basically the same code since rocketpy was created.
There are some quick improvements that we can do, while not changing the behavior of the class.

New behavior

The class still gives the same results, but with some refactoring like:

  • F-strings as faster in python, let's use them!
  • Added a docstring to the module, this may helps both users and devs. Now the help(rocketpy.prints.flight_prints) command will work.
  • useless comments were removed (don't state the obvious with comments, that's annoying and does help anyone)
  • docstrings were updated
  • no code line is longer than 88 columns (pylint and flake8 restriction)
  • improve parachute printing

Breaking change

  • No

Additional information

  • Reviewers, please let me know if you have any suggestion regarding these prints.
  • Here I provide a example of using the Flight.prints.all() after the refactor:
Initial Conditions

Initial time: 0.000 s
Position - x: 0.00 m | y: 0.00 m | z: 1471.47 m
Velocity - Vx: 0.00 m/s | Vy: 0.00 m/s | Vz: 0.00 m/s
Attitude (quaternions) - e0: 0.999 | e1: -0.044 | e2: -0.000 | e3: 0.000
Euler Angles - Spin φ : 0.00° | Nutation θ: -5.00° | Precession ψ: 0.00°
Angular Velocity - ω1: 0.00 rad/s | ω2: 0.00 rad/s | ω3: 0.00 rad/s
Initial Stability Margin: 2.590 c


Surface Wind Conditions

Frontal Surface Wind Speed: 3.61 m/s
Lateral Surface Wind Speed: 1.51 m/s
Wind Direction: 157.33°
Wind heading: 337.33°


Launch Rail

Launch Rail Length: 5.2 m
Launch Rail Inclination: 85.00°
Launch Rail Heading: 0.00°


Rail Departure State

Rail Departure Time: 0.414 s
Rail Departure Velocity: 22.713 m/s
Rail Departure Stability Margin: 2.664 c
Rail Departure Angle of Attack: 9.875°
Rail Departure Thrust-Weight Ratio: 7.952
Rail Departure Reynolds Number: 1.664e+05


Burn out State

Burn out time: 3.900 s
Altitude at burn out: 495.223 m (AGL)
Rocket speed at burn out: 212.057 m/s
Freestream velocity at burn out: 211.868 m/s
Mach Number at burn out: 0.625
Kinetic energy at burn out: 4.905e+05 J


Apogee State

Apogee Time: 22.902 s
Apogee Altitude: 3845.312 m (ASL) | 2373.846 m (AGL)
Apogee Freestream Speed: 4.577 m/s


Parachute Events

Parachute: Drogue
	Ejection time: 22.905 s
	Inflation time: 24.405 s
	Freestream speed at inflation: 15.011 m/s
	Altitude at inflation: 3834.365 m (ASL) | 2373.846 m (AGL)
Parachute: Main
	Ejection time: 99.181 s
	Inflation time: 100.681 s
	Freestream speed at inflation: 20.326 m/s
	Altitude at inflation: 2241.511 m (ASL) | 800.551 m (AGL)


Impact Conditions

Time of impact: 222.191 s
X impact: 479.991 m
Y impact: 1528.874 m
Altitude impact: 1471.466 m (ASL) | -0.000 m (AGL) 
Latitude: 33.0040016°
Longitude: -106.9698514°
Vertical velocity at impact: -6.169 m/s
Number of parachutes triggered until impact: 2


Stability Margin

Initial Stability Margin: 2.590 c at 0.00 s
Out of Rail Stability Margin: 2.664 c at 0.41 s
Maximum Stability Margin: 3.657 c at 3.65 s
Minimum Stability Margin: 2.590 c at 0.00 s


Maximum Values

Maximum Speed: 215.533 m/s at 3.44 s
Maximum Mach Number: 0.635 Mach at 3.44 s
Maximum Reynolds Number: 1.518e+06 at 3.36 s
Maximum Dynamic Pressure: 2.292e+04 Pa at 3.38 s
Maximum Acceleration During Motor Burn: 78.654 m/s² at 0.15 s
Maximum Gs During Motor Burn: 8.020 g at 0.15 s
Maximum Acceleration After Motor Burn: 10.368 m/s² at 15.03 s
Maximum Gs After Motor Burn: 1.057 Gs at 15.03 s
Maximum Stability Margin: 3.657 c at 3.65 s
Maximum Upper Rail Button Normal Force: 0.969 N
Maximum Upper Rail Button Shear Force: 2.366 N
Maximum Lower Rail Button Normal Force: 0.621 N
Maximum Lower Rail Button Shear Force: 1.518 N


Numerical Integration Settings

Maximum Allowed Flight Time: 600.00 s
Maximum Allowed Time Step: inf s
Minimum Allowed Time Step: 0.00e+00 s
Relative Error Tolerance: 1e-06
Absolute Error Tolerance: [0.001, 0.001, 0.001, 0.001, 0.001, 0.001, 1e-06, 1e-06, 1e-06, 1e-06, 0.001, 0.001, 0.001]
Allow Event Overshoot: True
Terminate Simulation on Apogee: False
Number of Time Steps Used: 1043
Number of Derivative Functions Evaluation: 2169
Average Function Evaluations per Time Step: 2.080

- F-strings as faster in python, let's use them!
- Added a docstring to the module!
- useless comments were removed
- docstrings were updated
- no code line is longer than 88 columns (pylint and flake8 restriction)
- improve parachute printing
@Gui-FernandesBR Gui-FernandesBR requested a review from a team as a code owner March 22, 2024 11:33
@Gui-FernandesBR Gui-FernandesBR added the Outputs Dedicated to visualizations enhancements like prints and plots label Mar 22, 2024
@Gui-FernandesBR Gui-FernandesBR added this to the Release v1.X.0 milestone Mar 22, 2024
@Gui-FernandesBR
Copy link
Member Author

Please merge the #572 first!

Copy link

codecov bot commented Mar 22, 2024

Codecov Report

Attention: Patch coverage is 88.37209% with 5 lines in your changes are missing coverage. Please review.

Project coverage is 72.66%. Comparing base (2456b11) to head (2a85ce8).
Report is 10 commits behind head on develop.

Files Patch % Lines
rocketpy/prints/flight_prints.py 88.37% 5 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #579      +/-   ##
===========================================
+ Coverage    72.65%   72.66%   +0.01%     
===========================================
  Files           59       59              
  Lines         9614     9603      -11     
===========================================
- Hits          6985     6978       -7     
+ Misses        2629     2625       -4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Base automatically changed from enh/adds-new-stability-margin-methods-to-flight to develop March 22, 2024 16:10
CHANGELOG.md Outdated Show resolved Hide resolved
@Gui-FernandesBR Gui-FernandesBR merged commit f286413 into develop Mar 24, 2024
11 checks passed
@Gui-FernandesBR Gui-FernandesBR deleted the mnt/refactor-flight-prints-module branch March 24, 2024 02:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Outputs Dedicated to visualizations enhancements like prints and plots
Projects
Status: Closed
Development

Successfully merging this pull request may close these issues.

2 participants